<div class="col-md-4">
    <form id="add_user_form">
        <table class="table table-condensed table-responsive table-hover table-striped table-bordered">
            <tr>
                <td>用户名</td>
                <td>
                    <input type="text" name="user">
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td>
                    <input type="text" name="password">
                </td>
            </tr>
            <tr>
                <td>角色</td>
                <td>
                    <select name="rule">
                        <option value="1">超级管理员</option>
                        <option value="0" selected="selected">管理员</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>是否启用</td>
                <td>
                    启用<input type="radio" checked="checked" name="status" value="1">
                    禁用<input type="radio" name="status" value="0">
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input class="btn btn-success" type="submit" id="add_user_submit" value="提交">
                    <a href="{:U('User/index')}" class="btn btn-info">返回</a>
                </td>
            </tr>
        </table>
    </form>
</div>
<script>
    $(document).ready(function () {
        $("#add_user_submit").click(function () {
            console.log('add user');
            var data = $("#add_user_form").serialize();
            console.log(typeof data,data);
            $.ajax({
                url: "/admin.php/User/addUser",
                data: data,
                dataType: 'json',
                success: function (res) {
                    if (res.code == 200) {
                        alert("添加成功");
                        window.location.href = "/admin.php/user/index";
                    } else {
                        alert("添加失败");
                    }
                }
            });
        });
    });
</script>